home *** CD-ROM | disk | FTP | other *** search
- Path: news.clark.net!not-for-mail
- From: eamick@clark.net (Eric Amick)
- Newsgroups: comp.lang.c
- Subject: Re: Problem with stringcopy
- Date: 6 Jan 1996 17:11:22 GMT
- Organization: the end of my rope
- Message-ID: <4cmafq$bm5@clarknet.clark.net>
- References: <4clguu$9fs@eagle.novo.dk> <yewvimppjz5.fsf@hyll.idt.unit.no>
- NNTP-Posting-Host: explorer.clark.net
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- X-Newsreader: TIN [UNIX 1.3 950726BETA PL0]
-
- Amund Tveit (amundt@pvv.unit.no) wrote:
- >[Morten Brun]
- >
- >| How do i do a partial stringcopy i.e. copy from a specific position in
- >| a string and a certain numbers of bytes. I am looking for a function
- >| like target = Stringcopy(source, startpos, length)
- >
- >You can try something like this :
- >char *Stringcopy(char *source, int startpos, size_t length)
- >{
- > char tmpstring[SIZEBIGENOUGH];
- > strncpy((char *)(source+startpos),tmpstring,length);
- > return tmpstring;
- >}
-
- This won't work as written; the first two arguments to strncpy() are
- reversed. The cast is also unnecessary.
-
- --
- Eric Amick eamick@clark.net
- Columbia, MD Public key available via finger
-